package com.example.tmxk.selvlet;

import com.example.tmxk.bean.NewsBean;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/newsDetail.html")
public class NewsDetailServlet extends HttpServlet {
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws SecurityException, IOException, ServletException {
        String newsID = req.getParameter("newsID");
        int id = Integer.parseInt(newsID);
        NewsBean newsBean = (new NewsBean()).getNewsByID(id);
        req.getAttribute("title",newsBean.getNewsByID(id));
        req.setAttribute("content",newsBean.getNewsContent());
        req.getRequestDispatcher("newsFrontDetail.jsp").forward(req,resp);
    }

}
